package com.tcm.smarthealth.enums;

import com.tcm.smarthealth.common.exception.BusinessException;
import org.springframework.http.HttpStatus;

import java.util.Arrays;

public enum ImageAnalysisType {

    TONGUE_DIAGNOSIS("舌诊分析"),
    WOUND_ASSESSMENT("创口识别"),
    SKIN_CONDITION("皮肤状态评估");

    private final String displayName;

    ImageAnalysisType(String displayName) {
        this.displayName = displayName;
    }

    public String getDisplayName() {
        return displayName;
    }

    public static ImageAnalysisType fromCode(String code) {
        if (code == null) {
            throw new BusinessException(HttpStatus.BAD_REQUEST, "分析类型不能为空");
        }
        String normalized = code.trim().toUpperCase();
        return Arrays.stream(values())
                .filter(type -> type.name().equals(normalized))
                .findFirst()
                .orElseThrow(() -> new BusinessException(HttpStatus.BAD_REQUEST, "不支持的分析类型"));
    }
}

